package com.systemframework.license.config;

import cn.hutool.core.convert.Convert;


import com.zmh.license.model.LicenseVerifyParam;
import com.zmh.license.verify.LicenseVerify;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author summer
 * @date 2023-03-13 14:58
 */
@Configuration
@Slf4j
@EnableConfigurationProperties(LicenseConfig.class)
public class LicenseAutoConfiguration implements CommandLineRunner {

    private LicenseConfig licenseConfig;

    @Autowired
    public void setLicenseConfig(LicenseConfig licenseConfig) {
        this.licenseConfig = licenseConfig;
    }

    @Override
    public void run(String... strings) throws Exception {
        log.info("开始安装license文件");
        LicenseVerifyParam convert = Convert.convert(LicenseVerifyParam.class, licenseConfig);
        LicenseVerify.install(convert);
    }
}
